<?php if (!defined('BASEPATH'))exit('No direct script access allowed');
/**
 * 首页控制器
 */
class Index extends MY_Controller {

    function __construct() {
        parent::__construct();
        $this->load->model('fund_model');
        $this->load->model('plat_model');
    }

    function index($parent_id) {
        header("Location:http://www.tan.com");exit;
        if($parent_id){
            $parent_user = $this->users_model->get_user_by_uid(intval($parent_id));
            if($parent_user){
                if($parent_user['status'] == 0){
                    redirect('error/index');
                }else{
                    $this->session->set_userdata('parent_id',$parent_id);
                }
            }
        }
                
        
        //体验专区
        $plats = $this->plat_model->get_list(array("is_hide"=>1,"is_index"=>1),0,12);
        foreach ($plats as $key=>$val){
            $plats[$key]["url"] = site_url("mplat_".$val['name_en']);
            $plats[$key]['max_award'] = number_format($val["max_award"]);
            $plats[$key]['logo_index'] = strstr($val['logo_index'], "http://") ? $val['logo_index'] : $this->img_url.$val['logo_index'];
        }
        $this->assign("plats", $plats);
        //推荐众筹
        $funds = $this->fund_model->get_list(array("is_recommand"=>1,"is_show"=>1),0,5);
        foreach ($funds as $key=>$val){
            $funds[$key]['url'] = site_url("mfunds/".$val['id']);
        }
        $this->assign("funds", $funds);
        //合作机构
        $partners = $this->db->select('*')->from('partners')->where(array('is_show'=>1))->order_by("sort", "asc")->limit(20, 0)->get()->result_array(); 
        foreach ($partners as $key=>$val){
            $partners[$key]['logo'] = strstr($val['logo'], "http://") ? $val['logo'] : $this->img_url.$val['logo'];
        }
        $this->assign("partners", $partners);
        $this->display('index/index.html');
    }
}
